clear all
set maxvar 5000

cd "/Users/tg2778/Dropbox/0_Reviews_RnRs/072022_JOP_Roads/v3_JOP/Replication - Roads"
log using "4_Log/11_Corruption.log"


global vars "ln_sancperkm ln_maintcostperkm ln_totalcostperkm qualityunsatisfactory ac_avgcomptime"

global vars2 "ln_sancperkm ln_maintcostperkm ln_totalcostperkm ac_avgcomptime"


*************************************************************

use "1_Data/AC_pre-delim_dataset.dta", clear

egen acstateid = concat(VD01_AC_id stateid),p("_")

foreach var of varlist $vars {
	egen x = std(`var')
	quietly areg change_incumbentvoteshare x, absorb(statedistrict2) cluster(acstateid)
	quietly estimates store `var'_1
	drop x
}

esttab *_1 using "2_Tables/Appendix_Table_G1.doc", keep(x) cells(b(star fmt(3)) se(par fmt(3))) mtitles("Sanction Cost" "Maintenance Cost" "Total Cost" "Poor Quality" "Completion Time") collabels(none) title(Effect of quality of roads provision on Δ incumbent vote share) varlabel(x "Quality") refcat(x "\b{Pre-delimitation AC}\b0", nolabel) rtf nonotes replace substitute("\fs20" "\fs16" "\fs24" "\fs20") varwidth(16) modelwidth(6)

*************************************************************

use "1_Data/AC_post-delim_dataset.dta", clear

egen acstateid = concat(VD01_AC_id stateid),p("_")

foreach var of varlist $vars {
	egen x = std(`var')
	quietly areg change_incumbentvoteshare x, absorb(statedistrict2) cluster(acstateid)
	quietly estimates store `var'_2
	drop x
}

esttab *_2 using "2_Tables/Appendix_Table_G1.doc", keep(x) cells(b(star fmt(3)) se(par fmt(3))) nomtitles nonumbers collabels(none) varlabel(x "Quality") refcat(x "\b{Post-delimitation AC}\b0", nolabel) rtf nonotes append substitute("\fs20" "\fs16" "\fs24" "\fs20") varwidth(16) modelwidth(6)


***********************************************************************

use "1_Data/PC_pre-delim_dataset_select.dta", clear

egen pcstate = concat(PC_no_2001 stateid),p("_")

foreach var of varlist $vars {
	egen x = std(`var')
	quietly areg change_incumbentvoteshare x, absorb(state2) cluster(pcstate)
	quietly estimates store `var'_3
	drop x
}

esttab *_3 using "2_Tables/Appendix_Table_G1.doc", keep(x) cells(b(star fmt(3)) se(par fmt(3))) nomtitles nonumbers collabels(none) varlabel(x "Quality") refcat(x "\b{Pre-delimitation PC}\b0", nolabel) rtf nonotes append substitute("\fs20" "\fs16" "\fs24" "\fs20") varwidth(16) modelwidth(6)


***********************************************************

use "1_Data/PC_post-delim_dataset_select.dta", clear

egen pcstate = concat(PC_no_2001 stateid),p("_")

foreach var of varlist $vars {
	egen x = std(`var')
	quietly areg change_incumbentvoteshare x, absorb(state2) cluster(pcstate)
	quietly estimates store `var'_4
	drop x
}

esttab *_4 using "2_Tables/Appendix_Table_G1.doc", keep(x) cells(b(star fmt(3)) se(par fmt(3))) nomtitles nonumbers collabels(none) varlabel(x "Quality") refcat(x "\b{Post-delimitation PC}\b0", nolabel) rtf nonotes append substitute("\fs20" "\fs16" "\fs24" "\fs20") varwidth(16) modelwidth(6)

*************************************************************


use "1_Data/upboothdataset_1km.dta", clear

foreach var of varlist $vars2 {
	egen `var'_std = std(`var')
}

global vars3 "ln_sancperkm_std ln_maintcostperkm_std ln_totalcostperkm_std qualitybadsqm ac_avgcomptime_std"

foreach var of varlist $vars3 {
	gen x = `var'
	quietly areg b_chgincvoteshare x, absorb(ac_id_09) cluster(uniqueboothid)
	quietly estimates store `var'_5
	drop x
}

esttab *_5 using "2_Tables/Appendix_Table_G1.doc", keep(x) cells(b(star fmt(3)) se(par fmt(3))) nomtitles nonumbers collabels(none) varlabel(x "Quality") refcat(x "\b{UP Booths (1 km)}\b0", nolabel) rtf nonotes append substitute("\fs20" "\fs16" "\fs24" "\fs20") varwidth(16) modelwidth(6) addnote("\i{Notes:}\i0 The dependent variable is change in incumbent vote share measured in %. The predictor for each model refers to quality measured as indicated in column headings. The OLS specification is the same as in main OLS results. Standard errors are clustered at the constituency level, except at the polling station level for UP Booths. *** p<0.001, ** p<0.01, * p<0.05")
log close
